package com.example.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.Utils.MD5Utils;
import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl  extends ServiceImpl<UserMapper, User> implements UserService{
    @Autowired
    private UserMapper userMapper;


    @Override
    public User login(String username) {
        return userMapper.find(username);
    }

    @Override
    public void register(User user) {
        if(userMapper.find(user.getUsername())==null){
        user.setPassword(MD5Utils.md5(user.getPassword()));
        userMapper.register(user);
        }

    }
}
